class PlayGround {
    constructor(root) {
        this.root = root;
        this.$playground = $(`<div class="playground"></div>`);

        this.hide();
        this.root.$ac_game.append(this.$playground);

        this.width = this.$playground.width();
        this.height = this.$playground.height();
        this.game_map = new GameMap(this);

        this.players = [];
        this.players.push(new Player(this, this.width / 2, this.height / 2, this.height * 0.05,
            this.get_random_color(), this.height * 0.25, true));

        for (let i = 0; i < 5; i++) {
            this.players.push(new Player(this, this.width / 2, this.height / 2, this.height * 0.05,
                this.get_random_color(), this.height * 0.25, false));
        }
    }

    get_random_color() {
        let r = 255 * Math.random();
        let g = 255 * Math.random();
        let b = 255 * Math.random();
        return `rgb(${r}, ${g}, ${b})`;
    }

    show() {
        this.$playground.show();
    }

    hide() {
        this.$playground.hide();
    }
}